package day2.homework;

import java.io.*;


public class Work5 {
    public static void main(String[] args) {
        File file = new File("d://IO//a//b//test.txt");
        try(
            FileReader fr = new FileReader("d://IO//test.txt");
            FileWriter fw = new FileWriter(file);
            BufferedReader br = new BufferedReader(fr);
            BufferedWriter bw = new BufferedWriter(fw);
        ) {
            File parentPath = file.getParentFile();
            if (!parentPath.exists()) parentPath.mkdirs();
            char[] ch = new char[20];
            int len = 0;
            while ((len = br.read(ch)) != -1){
                System.out.println(new String(ch,0,len));
                bw.write(ch,0,len);
            }
        }catch (IOException e){
            e.printStackTrace();
        }
    }
}
